home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 813 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.2 KB

  1. From: "joe (j.) halpin" <jhalpin@bnr.ca>
  2. Message-ID: <4iss70$82f@crchh327.rich.bnr.ca>
  3. X-Original-Date: Fri, 22 Mar 1996 00:28:16 +0000
  4. Path: in2.uu.net!bounce-back
  5. Date: 22 Mar 96 02:02:01 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Subject: Re: Referencing pointers after delete
  8. Newsgroups: comp.std.c++
  9. Organization: Bell-Northern Research, Richardson, TX
  10. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  11.     iQBFAgUBMVIKSuEDnX0m9pzZAQGFNAF9FadegeWAJQ5D0E/0lNpBKRJAL1/NyKfk
  12.     5n5fa96+ZbiBSwHSh8g2P+JvoduVpHXk
  13.     =de/9
  14.  
  15. In article <4isca2$t20@news.BelWue.DE>,
  16. Dietmar Kuehl <dietmar.kuehl@uni-konstanz.de> wrote:
  17. >Hi,
  18. >
  19. >joe (j.) halpin (jhalpin@bnr.ca) wrote:
  20. >: In 3.7.3.2.4 the January working paper says:
  21. >
  22. >: 4 A deallocation function can free the storage referenced by the pointer
  23. >:   given  as  its  argument and renders the pointer invalid.  The storage
  24. >:   can be made available for further allocation.  An invalid pointer con-
  25. >:   tains an unusable value:  it cannot even be used in an expression.
  26. >
  27. >: This sounds as though, in the following:
  28. >
  29. >: char *pc = new char[128];
  30. >: delete pc;
  31. >: pc = 0;
  32. >
  33. >: it makes the final assignment (an expression) invalid.
  34. >
  35. >No. You cannot use the value of the pointer but you can use the pointer
  36.  
  37. So, in the sentence above - "An invalid pointer contains an unusable
  38. value:  it cannot even be used in an expression." - the word 'it'
  39. refers to the value and not the pointer? That makes sense, although
  40. the phrasing is a bit ambiguous.
  41.  
  42. >(actually, you get undefined behavior in the code above because you
  43. >delete an array object with 'delete' instead of 'delete[]'; I assume
  44.  
  45. Mea culpa.
  46.  
  47. [...]
  48.  
  49. Thanks
  50.  
  51. Joe
  52. -- 
  53. Joe Halpin                             jhalpin@nortel.com
  54. Nortel Wireless                        (214) 684-5657 
  55. Richardson, TX  75083-3871             <standard disclaimer applies>
  56. -------------------------------------------------------------------------------
  57.  
  58. ---
  59. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  60. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  61. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  62. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  63. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  64.